package org.yawnage.framework 
{
	import org.yawnage.base.Debug;
	import org.yawnage.framework.server.Publisher;
	import org.yawnage.interfaces.framework.IPublisher;
	import org.yawnage.interfaces.framework.ISubscriber;
	 /**
	  * <p>//TODO:To be written</p>
	  * @author Berry Jordaan
	  * @date 2011/09/14 04:56 PM
	  * @copyright  Copyright © Berry/James 2011
	  * @version 1.0.0.0
	  * @description Class to abstract the Broker and hide all the things that the developer don't need to see
	  * @history Berry Jordaan on 2011/09/14 04:56 PM Created
	  */
	public class Diplomat 
	{
		
		public function Diplomat() 
		{
			throw new Error("Can't Instantiate Diplomat");
		}
		
		public static function publisherByName(publisherNameP:String) : IPublisher 
		{
			return Broker.instance.publisherByName(publisherNameP);
		}
		
		public static function printAll() : void 
		{
			Broker.instance.printAll();
		}
		
		public static function integrityCheck() : void 
		{
			Broker.instance.integrityCheck();
		}
		
		public static function printPublisherObjects() : void 
		{
			Broker.instance.printAllPublisherObjects();
		}
		
		public static function isPublisher(publisherNameP:String) : Boolean 
		{
			return Broker.instance.isPublisher(publisherNameP);
		}

		public static function subscribe(subscriberP:ISubscriber, callBackP:Function, publisherNameP:String, serviceNameP:String, priority:int=0) : void 
		{
			Broker.instance.subscribe(subscriberP, callBackP, publisherNameP, serviceNameP, priority);
		}
		
		/**
		 * 
		 * @param	accused The target object that takes responsibility for the syndication.
		 * @param	publisherNameP
		 * @param	serviceNameP
		 * @param	transportLayer
		 */
		public static function syndicateAs(accused:* ,publisherNameP:String, serviceNameP:String, transportLayer:TransportLayer = null) : void 
		{
			Debug.traceValue("Object ["+accused+"] syndicated for Publisher ["+publisherByName+"], service ["+serviceNameP+"] with transportLayer = "+(transportLayer != null));
			Broker.instance.syndicate(Publisher(Broker.instance.publisherByName(publisherNameP)), serviceNameP, transportLayer);
		}
	}

}